package com.JavaBasic;

public class ExceptionDemo {
	public static void main(String[] args) {
		try {
			// 检测异常
			int x = 10 / 0;
			int[] arr = {10,20,30};
		} catch (ArithmeticException e) {
			// 捕获异常
			// 除数为0异常
//			System.out.println("除数为0了");
			System.out.println("错误信息:" + e.getMessage());
			System.out.println("错误日志:" + e.toString());
			System.out.print("完整错误日志:");
			e.printStackTrace();
		} catch (ArrayIndexOutOfBoundsException e) {
			// 索引越界异常
			System.out.println("索引越界了");
		} catch (Exception e) {
			// 其他异常
			System.out.println("出问题了");
		}
		
		
	}
}
